package vip.yuange.gsyzm.controller;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import vip.yuange.gsyzm.utils.GSYZMOCRUtils;
import vip.yuange.gsyzm.utils.PublicUtils;
import vip.yuange.gsyzm.utils.YZMOCRUtils;

@Controller
public class YZMController{
	
	@PostMapping("/imgF") 
	@ResponseBody
	public String imgF(HttpServletRequest req, HttpServletResponse resp, @RequestParam("file")MultipartFile file) throws Exception {  	
		return YZMOCRUtils.ORC(ImageIO.read(file.getInputStream()));   
	} 
	
	@PostMapping("/imgFgsyzm") 
	@ResponseBody
	public String imgFgsyzm(HttpServletRequest req, HttpServletResponse resp, @RequestParam("file")MultipartFile file) throws Exception {
		return GSYZMOCRUtils.getGSYZMText(req.getParameter("color"),PublicUtils.bufferedImageToBase64(ImageIO.read(file.getInputStream())));   
	}
	
}